package godardbaudrin.tools;

import java.io.*;

/**
 * 
 * @author Destiny
 *
 */
public class Keyboard {
	
	/**
	 * Read an input String
	 * @return String read
	 */
	public static String readString(){
		String readLine = null;
		try{
			InputStreamReader reader = new InputStreamReader(System.in);
			BufferedReader input = new BufferedReader(reader);
			readLine = input.readLine();
		}
		catch(IOException err){
			System.exit(0);
		}
		return readLine;
	}
	
	/**
	 * Read Float number
	 * @return float number
	 */
	public static float readFloat(){
		float x = 0;
		try{
			String readLine = readString();
			x = Float.parseFloat(readLine);
		}
		catch(NumberFormatException err){
			System.out.println("*** An error was occured ***");
			System.exit(0);
		}
		return x;
	}
	
	/**
	 * Read Double number
	 * @return double number
	 */
	public static double readDouble(){
		double x = 0;
		try{
			String readLine = readString();
			x = Double.parseDouble(readLine);
		}
		catch(NumberFormatException err){
			System.out.println("*** An error was occured ***");
			System.exit(0);
		}
		return x;
	}
	
	/**
	 * Read integer number
	 * @return integer number
	 */
	public static int readInt(){
		int x = 0;
		try{
			String readLine = readString();
			x = Integer.parseInt(readLine);
		}
		catch(NumberFormatException err){
			System.out.println("*** An error was occured ***");
			System.exit(0);
		}
		return x;
	}
	
	/**
	 * Read long number
	 * @return long number
	 */
	public static long readLong(){
		long x = 0;
		try{
			String readLine = readString();
			x = Long.parseLong(readLine);
		}
		catch(NumberFormatException err){
			System.out.println("*** An error was occured ***");
			System.exit(0);
		}
		return x;
	}
	
}
